package cn.tedu.baking.controller;

import cn.tedu.baking.commons.response.JsonResult;
import cn.tedu.baking.pojo.vo.CategoryVO;
import cn.tedu.baking.service.ICategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.spring.web.json.Json;

import java.util.List;

@RestController
@RequestMapping("/v1/categories/")
public class CategoryController {
    @Autowired
    ICategoryService service;
    @GetMapping("type-list")
    public JsonResult typeList(){
        return JsonResult.ok(service.typeList());
    }
    @GetMapping("{id}/sub")
    public JsonResult subList(@PathVariable Long id){

        List<CategoryVO> list = service.subListByType(id);
        return JsonResult.ok(list);
    }
}
